package com.highspeed.bdk.service.physical;

import com.highspeed.bdk.bean.entity.physical.Board;
import com.highspeed.bdk.bean.entity.physical.Cpu;
import com.highspeed.bdk.repository.physical.CpuRepository;
import com.highspeed.bdk.service.base.BdkBaseService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by chenjiabin on 2018/3/23.
 */
@Service
@Transactional
public class CpuService extends BdkBaseService<Cpu, Integer> implements ICpuService {
    private static final Log LOG = LogFactory.getLog(CpuService.class);
    @Autowired
    private CpuRepository cpuRepository;
    @Autowired
    private IBoardService boardService;

    @Override
    public CpuRepository getRepository() {
        return cpuRepository;
    }

    @Override
    public Cpu move(Integer cpuId, Integer boardId) {
        Cpu cpu = findOne(cpuId);
        Board board = boardService.findOne(boardId);
        cpu.setBoard(board);
        return save(cpu);
    }
}
